/* kGLView */

#import <Cocoa/Cocoa.h>
#import "openGLheads.h"
#import "world.h"
#import "Camera.h"
#import "Crate.h"
#import "Rover.h"
#import "Path.h"


#define BITS_PER_PIXEL			32.0
#define DEPTH_SIZE				32.0
#define DEFAULT_TIME_INTERVAL	0.001
#define HOME					0
#define ROVERNORTH				1
#define ROVERUP					2
#define ROVERHAZCAM				3


@interface kGLView : NSOpenGLView
{
	bool	FullScreenOn;
	bool	first;			
	bool	logging;		// log file writing flag	
	char	CameraView;
	long	worldLoop;
	int		pathBredth;
	
	NSSpeechSynthesizer		*simTalk;
	Point3f			Start;
	Point3f			Goal;
	
	NSFileHandle	*StatFile;
	GLuint			base;    // Base display list for the font set
	NSPoint			mouseAct;
	NSLock			*objLock;
	world			*SimWorld;
	Camera			*Cam;
	Rover			*SR2;
	
	// Path list table view
	IBOutlet NSButton		*deletePath;
	IBOutlet NSTableView	*pathTableView;
	NSMutableArray			*SensorRangePaths;
	
	IBOutlet NSButton		*crossCheckButton;
	IBOutlet NSTextField	*breadthField;
	IBOutlet NSTextField	*angleField;
	IBOutlet NSButton		*recalcButton;
	IBOutlet NSButton		*nextWorldButton;
	IBOutlet NSProgressIndicator *calcSpinner;
	
	IBOutlet NSTextField	*stepDistField;
	IBOutlet NSTextField	*toGoalField;
	IBOutlet NSButton		*showAllPathwaysButton; // draw all the pathways calculated
	IBOutlet NSButton		*showDottedPathButton; // draw the white dotted line from start to goal
	IBOutlet NSButton		*showCspaceButton;	// draw obstacle Cspace flag
	IBOutlet NSButton		*showNumbersButton;	// draw obstacle number flag
	IBOutlet NSButton		*calcPathsButton;
	IBOutlet NSButton		*runButton;
	IBOutlet NSTextField	*worldsField;
	IBOutlet NSTextField	*obstacleCountField;
	IBOutlet NSColorWell	*pathColorWell;

	NSWindow		*FullScreenWindow;
	NSWindow		*StartingWindow;
	NSTimer			*time;
}

- (IBAction)fullScreen:(id)sender;

- (id)initWithFrame:(NSRect)frameRect;

- (void)initGL;
- (void) calcThread:(id)anObject;
- (void) calcLoopThread:(id)anObject;
- (void) checkStep;

////////////////////////////////////////////////
// functions for path table view
- (IBAction) deleteAPath:(id)sender;
- (IBAction) newPath:(id)sender;
- (IBAction) getWorldLoop:(id)sender;
- (IBAction) getObstacleCount:(id)sender;
- (IBAction) setPathColor:(id)sender;
- (IBAction) checkBreadthField:(id)sender;
- (IBAction) checkAngleField:(id)sender;
- (IBAction) recalcPaths:(id)sender;
- (IBAction) nextWorld:(id)sender;
- (IBAction) startStopButton:(id)sender;
- (IBAction) stepPathButton:(id)sender;
- (IBAction) stepField:(id)sender;

- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView
		objectValueForTableColumn:(NSTableColumn *)aTableColumn
		row:(int)rowIndex;
- (void)tableView:(NSTableView *)aTableView
		setObjectValue:(id)anObject
		forTableColumn:(NSTableColumn *)aTableColumn
		row:(int)rowIndex;
- (void)tableView:(NSTableView *)aTableView
  willDisplayCell:(id)aCell
   forTableColumn:(NSTableColumn *)aTableColumn
			  row:(int)rowIndex;

@end
